package com.neusoft.a132wxyorderingdish.model;

import com.neusoft.a132wxyorderingdish.common.Constants;
import com.neusoft.a132wxyorderingdish.iface.ShopIface;
import com.neusoft.a132wxyorderingdish.listener.RetrofitListener;
import com.neusoft.a132wxyorderingdish.service.ShopService;

import retrofit2.Call;

public class ShopModel extends RetrofitBaseModel implements ShopIface {
    private ShopService shopservice;

    public ShopModel() {
        this.shopservice = retrofit.create(ShopService.class);
    }

    public void getAllShops(RetrofitListener listener) {
        Call call = shopservice.getAllShops();
        bindCallback(call, listener, Constants.GETALLSHOPS);
    }

    @Override
    public void getFoodByShop(String shop_id, RetrofitListener listener) {
        Call call = shopservice.getFoodByShop(shop_id);
        bindCallback(call, listener, Constants.GETFOODBYSHOP);

    }

    @Override
    public void getShopById(String shop_id, RetrofitListener listener) {
        Call call = shopservice.getShopById(shop_id);
        bindCallback(call, listener, 3);
    }

    @Override
    public void getFoodById(String food_id, RetrofitListener listener) {
        Call call = shopservice.getFoodById(food_id);
        bindCallback(call, listener, Constants.GETFOODBYID);
    }

    @Override
    public void getAllUserComment(String user_id, RetrofitListener listener) {
        Call call = shopservice.getAllCommentsByFood(user_id);
        bindCallback(call, listener, Constants.GETALLCOMMENTS);
    }

    //收藏或取消店铺列表
    public void userCollectShop(String user_id, String shop_id, RetrofitListener listener) {
        Call call = shopservice.userCollectShop(user_id, shop_id);
        bindCallback(call, listener, Constants.USERCOLLECTSHOP);
    }

    //收藏或取消菜单列表
    public void userCollectFood(String user_id, String food_id, RetrofitListener listener) {
        Call call = shopservice.userCollectFood(user_id, food_id);
        bindCallback(call, listener, Constants.USERCOLLECTFOOD);
    }

    //判断是否收藏
    public void isCollected(String user_id, String shop_food_id, String flag, RetrofitListener listener) {
        Call call = shopservice.isCollected(user_id, shop_food_id, flag);
        bindCallback(call, listener, Constants.ISCOLLECTED);
    }

    @Override
    public void getAllUserCollection(String user_id, String flag, RetrofitListener listener) {
        Call call = shopservice.getAllUserCollection(user_id, flag);
        bindCallback(call, listener, Constants.USERALLCOLLECT);

    }

    //搜索页
    public void getFoodBySearch(String search, RetrofitListener listener) {
        Call call = shopservice.getFoodBySearch(search);
        bindCallback(call, listener, Constants.SEARCH);
    }
    //获取用户信息
    public void getUserById(String user_id, RetrofitListener listener) {
        Call call=shopservice.getUserById(user_id);
        bindCallback(call,listener,Constants.USERINFO);
    }

    //修改用户信息
    @Override
    public void updateUserById(String user_id, String username, String userpass, String mobilenum, String address, RetrofitListener listener) {
        Call call = shopservice.updateUserById(user_id, username, userpass, mobilenum, address);
        bindCallback(call, listener, Constants.UPDATEUSER);
    }
}
